﻿using NUnit.Framework;
using System.Collections.Generic;
namespace ThunkC_.Collections_.Dictionary
{
    /// <summary>
    /// ValueCollectionFixture
    /// </summary>
    [TestFixture]
    public class ValueCollectionFixture
    {
        #region Enumerator
        /// <summary>
        /// EnumeratorFixture
        /// </summary>
        [TestFixture]
        public class EnumeratorFixture
        {
            [Test]
            public void Dispose_OneElementDictionary_NotNull()
            {
                var dictionary = new Dictionary<int, int>();
                dictionary.Add(1, 1);
                var valueCollection = new Dictionary<int, int>.ValueCollection(dictionary);
                var enumerator = valueCollection.GetEnumerator();
                //
                enumerator.Dispose();
            }

            [Test]
            public void MoveNext_OneElementDictionary_EqualsTrue()
            {
                var dictionary = new Dictionary<int, int>();
                dictionary.Add(1, 1);
                var valueCollection = new Dictionary<int, int>.ValueCollection(dictionary);
                var enumerator = valueCollection.GetEnumerator();
                //
                Assert.IsTrue(enumerator.MoveNext());
            }

            [Test]
            public void getCurrent_OneElementDictionary_NotNull()
            {
                var dictionary = new Dictionary<int, int>();
                dictionary.Add(1, 1);
                var valueCollection = new Dictionary<int, int>.ValueCollection(dictionary);
                var enumerator = valueCollection.GetEnumerator();
                enumerator.MoveNext();
                //
                Assert.IsNotNull(enumerator.Current);
            }
        }
        #endregion Enumerator

        [Test]
        public void Constructor_Valid_NotNull()
        {
            var dictionary = new Dictionary<int, int>();
            var valueCollection = new Dictionary<int, int>.ValueCollection(dictionary);
            Assert.IsNotNull(valueCollection);
        }

        [Test]
        public void CopyTo_KeyCollectionWithOneElementDictionary_FirstElementEqualsOne()
        {
            var dictionary = new Dictionary<int, int>();
            dictionary.Add(1, 1);
            var valueCollection = new Dictionary<int, int>.ValueCollection(dictionary);
            //
            int[] values = new int[1];
            valueCollection.CopyTo(values, 0);
            Assert.AreEqual(1, values[0]);
        }

        [Test]
        public void GetEnumerator_KeyCollectionWithOneElementDictionary_NotNull()
        {
            var dictionary = new Dictionary<int, int>();
            dictionary.Add(1, 1);
            var valueCollection = new Dictionary<int, int>.ValueCollection(dictionary);
            //
            Assert.IsNotNull(valueCollection.GetEnumerator());
        }

        [Test]
        public void getCount_KeyCollectionWithOneElementDictionary_CountEqualsOne()
        {
            var dictionary = new Dictionary<int, int>();
            dictionary.Add(1, 1);
            var valueCollection = new Dictionary<int, int>.ValueCollection(dictionary);
            //
            Assert.AreEqual(1, valueCollection.Count);
        }
    }
}
